#include "historycontroldatawidget.h"
#include "ui_historycontroldatawidget.h"

HistoryControlDataWidget::HistoryControlDataWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::HistoryControlDataWidget)
{
    ui->setupUi(this);
    initUI();
    model = new QSqlTableModel(this);
}

HistoryControlDataWidget::~HistoryControlDataWidget()
{
    delete ui;
}
void HistoryControlDataWidget::initUI()
{
    mainLayout = new QVBoxLayout;
    buttonLayout = new QHBoxLayout;

    buttonLayout->addStretch();
    buttonLayout->addWidget(ui->pushButton);
    buttonLayout->addSpacing(5);
    mainLayout->addWidget(ui->tableView);
    mainLayout->addLayout(buttonLayout);

    setLayout(mainLayout);

    connect(ui->pushButton, SIGNAL(clicked()),this,SLOT(updataTable()));


}
void HistoryControlDataWidget::selectTable(const QString &tableName)
{
    model->setTable(tableName);
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    model->select();
}
void HistoryControlDataWidget::showTable()
{
    ui->tableView->setModel(model);
}
void HistoryControlDataWidget::updataTable()
{
}
